package Textbookmanagement;

import java.util.Arrays;
import java.util.Scanner;

public class Sell {
    Scanner sc = new Scanner(System.in);
    public static double price;
    public static String name;

    public void show() {
        System.out.println("1.出售录入         2.销售信息查询");
        System.out.println("                  0.退出");
        System.out.println("请输入功能：");
    }

    public void Saleentry() {//出售录入
        System.out.println("请输入卖出的书籍名称：");
        name = sc.nextLine();
        try {
            System.out.println("请输入出售的价格：");
            price = sc.nextDouble();
        } catch (Exception e) {
            System.out.println("请重新输入出售的价格：");
            price = sc.nextDouble();
        }

    }

    public void SalesInquiries() {//销售查询
        System.out.println("卖出书籍：" + "《" + name + "》" + "售价为" + price + "元");

    }

    public void delete() {
        if (name == null) {
            String str1 = Order.nameprice;
            String regex = "[\\s\\d\\p{Punct}]+";
            String[] dihitword = str1.split(regex);
            System.out.println("今日共预定" + dihitword.length + "本书:");

            for (String s : dihitword) {
                System.out.println("《" + s + "》");
            }
        } else {
            String str1 = Order.nameprice;
            String str2 = name;
            String regex = "\\d+";
            String str3 = Arrays.toString(str1.split(regex));
            String str4 = str3.replace(str2, "");
            System.out.println(str4.replace(",", ""));

        }
    }
}


